# Define your item pipelines here
#
# Don't forget to add your pipeline to the ITEM_PIPELINES setting
# See: https://docs.scrapy.org/en/latest/topics/item-pipeline.html
# useful for handling different item types with a single interface
import codecs
import time
from itemadapter import ItemAdapter
class WeatherPipeline:
    def process_item(self, item, spider):
        today=time.strftime('%Y%m%d',time.localtime())
        filename=today+'.txt'
        with codecs.open(filename,'a','utf-8')as fp:
            fp.write(f'{item["city"]},  {item["date"]}, {item["wea"]}, {item["tem"]}\n')
        return item
